package com.example.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.entity.Points;
import com.example.service.PointsService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@RestController
public class PointsController {
	@Resource
	private PointsService pointsService;

	@GetMapping("/add_points")
	public String addPoints(Integer memberId, Integer points) throws JsonProcessingException {
		Map<String, Object> result = new HashMap<>();
		Points entity = pointsService.addPoints(memberId, points);
		result.put("code", "0");
		result.put("message", "add points success");
		return new ObjectMapper().writeValueAsString(result);
	}
}
